{#

Notice for plugins and theme developer:     Do not extend this template!

This template will be rendered over the `block` function.
Templates which are rendered over the `block` function can not be extended.
Instead of extending this template, simply extend the `base.html.twig` (or the document specific template) and override the block you want.
All blocks of this template are available in the template which renders this template over the `block` function.

#}

{% block position_header %}
    <thead>
        <tr class="line-item-table-header">
            {% block document_line_item_table_head %}
                {% block document_line_item_table_head_position %}
                    {% if config.displayLineItemPosition %}
                        <th>{{ 'document.lineItems.header.position'|trans|sw_sanitize }}</th>
                    {% endif %}
                {% endblock %}

                {% block document_line_item_table_head_product_number %}
                    <th class="product-number">{{ 'document.lineItems.header.productNumber'|trans|sw_sanitize  }}</th>
                {% endblock %}

                {% block document_line_item_table_head_label %}
                    <th class="product-label">{{ 'document.lineItems.header.label'|trans|sw_sanitize }}</th>
                {% endblock %}

                {% block document_line_item_table_head_quantity %}
                    <th class="numbers">{{ 'document.lineItems.header.quantity'|trans|sw_sanitize }}</th>
                {% endblock %}

                {% block document_line_item_table_head_prices %}
                    {% if config.displayPrices %}
                        {% set companyTaxEnabled = billingAddress.country.companyTax.enabled %}
                        {% set displayAdditionalNoteDelivery = config.displayAdditionalNoteDelivery %}
                        {% set isDeliveryCountry = billingAddress.country.id in config.deliveryCountries %}
                        {% set taxStatusGross = order.price.taxStatus == constant('Shopware\\Core\\Checkout\\Cart\\Price\\Struct\\CartPrice::TAX_STATE_GROSS') %}
                        {% set taxStatusNet = order.price.taxStatus == constant('Shopware\\Core\\Checkout\\Cart\\Price\\Struct\\CartPrice::TAX_STATE_NET') %}

                        {% set displayVAT = not companyTaxEnabled or not (displayAdditionalNoteDelivery and isDeliveryCountry) %}

                        {% block document_line_item_table_head_tax_rate %}
                            <th class="numbers">{{ 'document.lineItems.header.tax'|trans|sw_sanitize }}</th>
                        {% endblock %}
                        {% block document_line_item_table_head_unit_price %}
                            <th class="numbers incl-vat">
                                {{ 'document.lineItems.header.unitPrice'|trans|sw_sanitize }}
                                {% if displayVAT %}
                                    {% if taxStatusGross %}
                                        <span>{{ 'document.lineItems.inclVAT'|trans|sw_sanitize }}</span>
                                    {% elseif taxStatusNet %}
                                        <span>{{ 'document.lineItems.exclVAT'|trans|sw_sanitize }}</span>
                                    {% endif %}
                                {% endif %}
                            </th>
                        {% endblock %}
                        {% block document_line_item_table_head_total_price %}
                            <th class="numbers incl-vat">
                                {{ 'document.lineItems.header.total'|trans|sw_sanitize }}
                                {% if displayVAT %}
                                    {% if taxStatusGross %}
                                        <span>{{ 'document.lineItems.inclVAT'|trans|sw_sanitize }}</span>
                                    {% elseif taxStatusNet %}
                                        <span>{{ 'document.lineItems.exclVAT'|trans|sw_sanitize }}</span>
                                    {% endif %}
                                {% endif %}
                            </th>
                        {% endblock %}
                    {% endif %}
                {% endblock %}
            {% endblock %}
        </tr>
    </thead>
{% endblock %}
